package com.controller.wmt;

import com.entity.Room;
import com.service.wmt.RoomService;
import com.util.gzp.AjaxResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("room")
public class RoomController {
    @Resource
    private RoomService roomService;

    @RequestMapping("changeState")
    @ResponseBody
    public AjaxResponse changeState(Integer roomid,Integer roomstatusid){
        System.out.println("RoomController.changeState roomid :"+roomid+"  roomstatusid  ="+roomstatusid);
        AjaxResponse ajaxResponse = AjaxResponse.success(roomService.updateStatus(roomid,roomstatusid));
        return ajaxResponse;
    }

    @RequestMapping("listAllRoom")
    @ResponseBody
    public  AjaxResponse listAllRoom(Integer buildingid){
        return AjaxResponse.success( roomService.findOV(buildingid));
    }
    @RequestMapping("listAllRoomByPage")
    @ResponseBody
    public  AjaxResponse listAllRoomByPage(Integer buildingid,Integer pageNum, Integer pageSize){
        System.out.println("RoomController.listAllRoomByPage buildingid"+buildingid +"  pageSize　＝"+ pageSize+" PageNum= "+pageNum);
        System.out.println("RoomController.listAllRoomByPage"+(roomService.getRoomList(buildingid,pageNum,pageSize)).getData());
        return AjaxResponse.success( roomService.getRoomList(buildingid,pageNum,pageSize));
    }
    @RequestMapping("findRoomByid")
    @ResponseBody
    public AjaxResponse findRoomByid(Integer roomid){
        return AjaxResponse.success(roomService.findById(roomid));
    }
}
